<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%String m_id = (String)session.getAttribute("member");%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript" src="/bigjo/js/jquery.js"></script>
<title>Insert title here</title>
</head>
<style type="text/css">
	#re{
		position:relative;
		width: 30Em;
		height: 100px;
	}
	
	#rereply{
		margin-left: 50px;
	}
	
	.insertreply{
		font-size: 13px;
	}
</style>
<script type="text/javascript">
jQuery.noConflict();
jQuery("#reinput").click(function(){
	var idx = document.URL.indexOf("bigjo");
	var str = document.URL.substring(0,idx+5);
	var context = jQuery("#retext").val();
	var sb_no = jQuery("#replysb_no").val();
	alert(context);
	if(context == ""){
		alert("댓글을 입력해 주세요");
		return;
	}
	else{
		jQuery.ajax({
			url: str + "/sBoardReply.reply?context="+context+"&sb_no="+sb_no,
			error:function(data){
				alert("오류 발생");
			},
			success : function(data){
				jQuery("#replyInsert").prepend(data);
			}
		});
	}
});
jQuery.noConflict();
	var sr_no = jQuery(".test").attr("id");
	jQuery(".insertreply").click(function(){
		var idx = document.URL.indexOf("bigjo");
		var str = document.URL.substring(0,idx+5);
		var sr_no = jQuery(this).attr("id");
		var sb_no = jQuery("#replysb_no").val();
		alert("게시판 시퀀스값: "+sb_no);
		alert("댓글의 시퀀스값: "+sr_no);
		jQuery.ajax({
			url:str + "/replyform.reply?sr_no="+sr_no+"&sb_no="+sb_no,
			error:function(data){
				alert("오류 발생");
			},
			success : function(data){
				jQuery("#test"+sr_no).html(data);
			}
		});
	});
	
	jQuery.noConflict();
	jQuery(".reupdate").click(function(){
		var idx = document.URL.indexOf("bigjo");
		var str = document.URL.substring(0,idx+5);
		var sr_no = jQuery(this).attr("id");
		alert("시퀀스 값 : "+sr_no);
		jQuery.ajax({
			url: str + "/replyUpdate.reply?sr_no="+sr_no,
			error:function(data){
				alert("오류 발생");
			},
			success : function(data){
				jQuery("."+sr_no).html(data);
			}
		});
	});
	
	jQuery.noConflict();
	jQuery(".redelete").click(function(){
		var idx = document.URL.indexOf("bigjo");
		var str = document.URL.substring(0,idx+5);
		var sr_no = jQuery(this).attr("id");
		var sb_no = jQuery("#replysb_no").val();
		if (confirm("정말 삭제하시겠습니까??") == true){    //확인
			 jQuery.ajax({
				url: str + "/replyDelete.reply?sr_no="+sr_no+"&sb_no="+sb_no,
				error:function(data){
					alert("오류 발생");
				},
				success : function(data){
					jQuery(".reply").html(data);
				}
			}); 
		}else{   //취소
		return;
		}
		  
	});
</script>
<body>
<div id="re">

	<div align="left">	<!-- 이곳은 해당 댓글에 댓글을 달기위해 사용하는 버튼  -->
		<c:forEach var="reply" items="${reply}">
		<div>
			<input type="hidden" id="${reply.sr_no}" class="replybutton">
			<label>${reply.sr_m_id}</label>&nbsp;<label>${reply.sr_context}</label>&nbsp;&nbsp;&nbsp;<a class="insertreply" name="${reply.sr_sb_no}" id="${reply.sr_no}"style="size: 10px">댓글</a>			
		</div>
		<div>
			<%-- <td colspan="3"><div class="${reply.sr_no}List"></div></td> --%>
			<jsp:include page="/BoardReplyreply.reply?sr_no=${reply.sr_no}"></jsp:include>
		</div>
		</c:forEach>
	</div>
	
	<div id="replyInsert"></div>
	<% String reply = "";
	if(m_id == null){
		reply = "disabled='disabled'";}else{ reply = ""; }
	String member = "name="+m_id;
	%>
	<div id="re">	<!-- 이곳은 현재 게시글에서 새로운 댓글을 달기위한 입력 버튼과 텍스트 바 입니다. -->
		<input type="text" id="retext" value="" <%=reply %> style="width: 270px"><input type="button" id="reinput" value="입력">
		<input type="hidden" id="replysb_no" value="${sb_no}">
	</div>
</div>
</body>
</html>